package szcg.framework.library.utils.response;

import com.alibaba.fastjson2.JSON;

public class ResponseUtils {

    /**
     * 000:成功
     * 010：失败
     * 011：权限不足
     * ...
     **/
    public static <T> String generateSucceed(T data) {
        ResponseBean<T> resultBean = new ResponseBean<>();
        resultBean.code = "000";
        resultBean.des = "请求成功";
        resultBean.data = data;
        return JSON.toJSONString(resultBean);
    }

    public static <T> String generateFail(String des) {
        ResponseBean<T> resultBean = new ResponseBean<>();
        resultBean.code = "001";
        resultBean.des = des;
        return JSON.toJSONString(resultBean);
    }

    public static <T> String generateFailForCode(String code, String des) {
        ResponseBean<T> resultBean = new ResponseBean<>();
        resultBean.code = code;
        resultBean.des = des;
        return JSON.toJSONString(resultBean);
    }

}
